package com.anji.util;

import java.io.IOException;

import javax.xml.bind.JAXBException;

import com.anji.hyperneat.modular.ModularHyperNeatMultiNetTranscriber;
import com.anji.topology.Topology;
import com.anji.topology.XmlUtil;

/**
 * 
 * @author slusk
 *
 */
public class ExtendedProperties extends Properties {
	public static final String TOPOLOGY_FILE_KEY = "ann.hyperneat.topology.descriptor.file";
	public static final String TOPOLOGY_KEY = "ann.hyperneat.topology";
	
	/**
	 * 
	 * @param resource
	 * @throws IOException
	 */
	public ExtendedProperties( String resource ) throws IOException {
	    super(resource);
	    
	    // Initialize and store the GridNet topology descriptor, if present
	    String topologyDescriptorFile = this.getProperty(TOPOLOGY_FILE_KEY);
	    if (topologyDescriptorFile != null) {
			Topology topology = null;
			try {
				topology = XmlUtil.getTopologyDescriptor(topologyDescriptorFile);
			} catch (JAXBException e) {
				e.printStackTrace();
			}
			if (null != topology) {
				this.put(TOPOLOGY_KEY, topology);
			}
	    }	    
	}
}
